<?php
	//Xay dung tim kiem
	$ssFilter 		= $this->arrParam['ssFilter'];
	$page = '';
	if(isset($this->arrParam['page'])){
		$page = '/page/' . $this->arrParam['page'];
	}
	$action_link 	= $this->baseUrl($this->currentController . '/filter/type/order');
	
	$lblName 		= $this->cmsLinkSort('Tên chương trình','c.name',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblModified_by 	= $this->cmsLinkSort('Sửa lần cuối','c.name_modified_by',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblNoidung  	= $this->cmsLinkSort('Nội Dung','c.content',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblNgaybatdau	= $this->cmsLinkSort('Ngày bắt đầu','c.ngaybatdau',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblNgayketthuc	= $this->cmsLinkSort('Ngày kết thúc','c.ngayketthuc',$ssFilter,$this->imgUrl . '/admin',$action_link);
	
	$lblID 			= $this->cmsLinkSort('ID','c.id',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$keywords = $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort txtsearch'));
	
	 
	$selectLanguages = $this->slbLanguages;
	$linkSlbLanguages = $this->baseUrl($this->currentController . '/filter/type/lang');
	$selectLanguages = $this->formSelect('lang_code',$ssFilter['lang_code'],array('onchange'=>"OnSubmitForm('" .$linkSlbLanguages ."')"),$selectLanguages);
	
	$linkSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/1');
	$btnSearch = $this->formButton('search-now','Tìm',array('class' => 'btnsearch', 'onclick'=>"OnSubmitForm('" .$linkSearch . "')"));
	
	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0');
	$btnResetSearch = $this->formButton('clear-keywords','Xóa',array('class' => 'btnsearch', 'onclick'=>"OnSubmitForm('" .$linkResetSearch ."')"));
	
	$strSearch = $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch;

	$strSearchRight = '';
?>

<div class="left_content">
	<?php echo $this->render($this->arrParam['controller'] . '/toolbar/left.php');?>
	
</div>

<div class="right_content">
	<div class="appContent">
	<?php echo $this->render($this->arrParam['controller'] . '/toolbar/index.php');?>
		
	<form action="" method="post" name="appForm">
	 
	<div class="tblForm">
	
		
		<div class="formList goc5">
			<div class="appTop goct5">
				<div class="block_filter">
					<div class="fl">
						<div class="listSearch">
							<?php echo $strSearch; ?>
							<div class="clr"></div>			
						</div>
					</div>
					<div class="fr">
						<?php echo $strSearchRight;?>
					</div>
					<div class="clr"></div>
				</div>
			</div>
			<div class="appBody">
				<table class="tblList">
					<tr>
						<th width="30">#</th>
						<th width="20"><input type="checkbox" name="checkbox" id="checkbox" onclick="checkedAll()"></th>
						<th><?php echo $lblName;?></th>
						<th><?php echo $lblModified_by;?></th>
						<th><?php echo $lblNgaybatdau;?></th>
						<th><?php echo $lblNgayketthuc; ?></th>
						<th width="60">Thao tác</th>
					</tr>
					
				<?php
					$date = new Zend_Date();
					$time= $date->get('dd-MM-YYYY');
					foreach ($this->Items as $key => $val){
						$id 				= $val['id'];
						$name 				= $val['name'];
						$NameModified_by	= $val['name_modified_by'];
						$Ngaybatdau 		= $val['ngaybatdau'];
						$Ngayketthuc 		= $val['ngayketthuc'];
						
						if($Ngayketthuc==null){
							$red='';
							$dahethan='';
						}elseif ($date->compare($Ngayketthuc,Zend_Date::DATE_SHORT) == 1){
							$red='red';
							$dahethan=' - <b>(Đã hết hạn)</b>';
						}
							
						$linkInfo		= $this->baseUrl($this->currentController . '/info/id/' . $id . $page);
						$btnInfo		= $this->cmsIconButton('Xem thông tin', $this->imgUrl . '/admin/icon_info.png', $linkInfo);
						
						$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id . $page);
						$btnEdit		= $this->cmsIconButton('Sửa', $this->imgUrl . '/admin/icon_edit.png', $linkEdit);
						
						$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id . $page);
						$btnDelete		= $this->cmsIconButton('Xóa', $this->imgUrl . '/admin/publish_r.png', $linkDelete);
						
						$strIconButton 	=  $btnEdit.' '.$btnDelete;
						
						$alias = '<p class="smallsub">(Url: ' . $val['url'] . ' )</p>';
						$hoten 	= '<b><a href="' . $linkInfo . '">' . $hoten . '</a></b>';
					
						$cid 			= $this->formCheckbox('cid[]',$val['id']);
						
						$classRow = 'row1';
						if($key % 2 == 0)
						$classRow = 'row0';
							
				?>
				<tr class="<?php echo $classRow;?>">
					<td align="center"><?php echo $key + 1;?></td>
					<td align="center"><?php echo $cid;?></td>
					<td align="left"><a class="<?php echo $red;?>" href="<?php echo $linkEdit;?>"><?php echo $name.' '.$dahethan;?></a></td>
					<td align="center"><?php echo $NameModified_by;?></td>
					<td align="center"><?php echo $Ngaybatdau;?></td>
					<td align="center"><?php echo $Ngayketthuc;?></td>
					<td align="center"><?php echo $strIconButton;?></td>
				</tr>
				<?php
					} 
				?> 
				</table>
			</div>
			<div class="appBottom">
				<div class="pagination">
					<?php
						$currentUrl = $this->baseUrl($this->currentController . '/index');
						echo $this->paginationControl($this->paginator,'Sliding','pagination.phtml',array('currentUrl'=>$currentUrl)); 
					?>
				</div>
			</div>
		</div>
	</div> 
	</form>
	</div>
</div>
<div class="clr"></div>	
